/************************************************************************

								Heroes IV
					  Copyright 2001, The 3DO Company

	------------------------------------------------------------------
  						 combat_ai_melee_action.h

	$Header: $

	$NoKeywords: $

 ************************************************************************/

#if !defined( COMBAT_AI_MELEE_ACTION_H_INCLUDED )
#define COMBAT_AI_MELEE_ACTION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "abstract_combat_ai_action.h"
#include "attack_angle.h"
#include "combat_ai_action_ptr.h"
#include "combat_creature_ptr.h"
#include "combat_object_ptr.h"


// A representation of the "hand-to-hand attack" action
class t_combat_ai_melee_action : public t_abstract_combat_ai_action
{
public:
	t_combat_ai_melee_action( t_battlefield&		battlefield,
							  t_combat_creature_ptr target, 
							  const t_attack_angle&	attack_angle,
							  bool					unreachable );


	const t_attack_angle &  get_attack_angle() const;
	t_combat_creature_ptr	get_target() const;
	bool					get_unreachable() const;
	int						get_turns() const;

	virtual void weigh_action(t_combat_ai const& owner);
	virtual void perform_action(void);

private:
	t_attack_angle			m_attack_angle; // Angle to attack from
	bool					m_blocked;
	t_map_point_2d			m_destination;
	t_combat_object_ptr		m_obstacle;
	t_combat_creature_ptr	m_target; // Target of attack
	int						m_turns;
	bool					m_unreachable; // If true, we cannot actually reach the target at the moment but want to weight the value of eventually attacking it

	double	get_action_weight(t_combat_ai const& owner, bool retaliate );
};

typedef t_counted_ptr<t_combat_ai_melee_action> t_combat_ai_melee_action_ptr;

inline
t_combat_creature_ptr t_combat_ai_melee_action::get_target() const
{
	return m_target;
}

inline
const t_attack_angle &t_combat_ai_melee_action::get_attack_angle() const
{
	return m_attack_angle;
}

inline int t_combat_ai_melee_action::get_turns() const
{
	return m_turns;
}

inline
bool t_combat_ai_melee_action::get_unreachable() const
{
	return m_unreachable;
}

t_combat_ai_action_ptr generate_best_melee_action( t_combat_ai&	combat_ai );

#endif // COMBAT_AI_MELEE_ACTION_H_INCLUDED
